﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccessLayer;
using Common;

namespace BussinessLayer
{
    public class LoiBO : BaseBO
    {
        #region Singleton implemented
        private static LoiBO _instance;
        private LoiBO()
        { }
        public static LoiBO getInstance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new LoiBO();
                }
                return _instance;
            }
        }
        #endregion

        public IEnumerable<Loi> GetAllLoi()
        {
            return _dao.Loi.GetAllLoi();
        }
        public Loi GetLoiById(int id)
        {
            return _dao.Loi.GetLoiById(id);
        }
        public bool UpdateLoi(Loi inLoi)
        {
            return _dao.Loi.UpdateLoi(inLoi);
        }
        public bool InsertLoi(Loi inLoi)
        {
            return _dao.Loi.InsertLoi(inLoi);
        }
        public bool DelLoi(int id)
        {
            return _dao.Loi.DelLoi(id);
        }
        public string GenerateMaLoi()
        {
            Loi aObj = _dao.Loi.GetLastRecord();
            if (aObj != null)
            {
                return Utils.GenerateCode(CodeType.Loi, aObj.Id + 1);
            }
            else
            {
                return Utils.GenerateCode(CodeType.Loi, 1);
            }

        }

    }
}
